package com.evil.application.pojo.dto.order;

import cn.hutool.core.bean.BeanUtil;
import com.evil.application.pojo.dto.button.ButtonInfoRespDTO;
import com.evil.application.pojo.entity.ApplicationOrder;
import com.evil.common.application.dto.order.OrderPageDataRespDTO;
import com.evil.common.application.dto.order.data.ControlDataDTO;
import com.evil.common.application.dto.process.node.btn.NodeButtonConfigDTO;
import com.evil.common.core.enums.SwitchEnum;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.ArrayList;
import java.util.List;

/**
 * 订单信息 返回实体
 *
 * @author liyang
 * @date 2022-08-08 00:00
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class OrderDetailRespDTO extends OrderPageDataRespDTO {

    /**
     * 申请人名称
     */
    private String creatorName;

    /**
     * 特殊控件数据
     */
    private List<ControlDataDTO> specialData;

    /**
     * 应用名称
     */
    private String applicationName;

    /**
     * 允许查看流程日志(0:否, 1:是)
     */
    private Integer processLog;

    /**
     * 处理反馈(0:否, 1:是)
     */
    private Integer handleFeedback;

    /**
     * 待办转交(0:否, 1:是)
     */
    private Integer pendingDivert;

    /**
     * 节点撤回(0:否, 1:是)
     */
    private Integer nodeBack;

    /**
     * 流程回退(0:否, 1:是)
     */
    private Integer nodeFallback;

    /**
     * 流程拒绝(0:否, 1:是)
     */
    private Integer nodeRefuse;

    /**
     * 流程可发起留言(0:否, 1:是)
     */
    private Integer nodeMessage;

    /**
     * 流程按钮配置
     */
    private NodeButtonConfigDTO nodeButton;

    /**
     * 自定义按钮
     */
    private List<ButtonInfoRespDTO> buttons;

    public OrderDetailRespDTO() {
        this.processLog = SwitchEnum.YES.getId();
        this.handleFeedback = SwitchEnum.YES.getId();
        this.pendingDivert = SwitchEnum.NO.getId();
        this.nodeBack = SwitchEnum.NO.getId();
        this.nodeFallback = SwitchEnum.NO.getId();
        this.nodeRefuse = SwitchEnum.NO.getId();
        this.nodeMessage = SwitchEnum.YES.getId();
        this.nodeButton = new NodeButtonConfigDTO();
        this.buttons = new ArrayList<>();
    }

    public OrderDetailRespDTO(ApplicationOrder applicationOrder) {
        BeanUtil.copyProperties(applicationOrder, this);
        this.processLog = SwitchEnum.YES.getId();
        this.handleFeedback = SwitchEnum.YES.getId();
        this.pendingDivert = SwitchEnum.NO.getId();
        this.nodeBack = SwitchEnum.NO.getId();
        this.nodeFallback = SwitchEnum.NO.getId();
        this.nodeRefuse = SwitchEnum.NO.getId();
        this.nodeMessage = SwitchEnum.YES.getId();
        this.nodeButton = new NodeButtonConfigDTO();
        this.buttons = new ArrayList<>();
    }
}
